<h1>RESERVAS</h1>

<?php include_partial('filtro', array('formulario'=>$formulario)) ?>

<?php $fecha = date('d-m-Y') ?>


<?php echo "La fecha actual es: ".$fecha ?>

<?php echo "Total de Reservas: " .count($gestdent_reserva_list) ?>
<br>
<?php echo "Total de Horas: " .count($gestdent_hora_list) ?>
<br>
<?php echo "Total de Box: " .count($gestdent_box_list) ?>
<br>



<?php $agenda = array(); ?>
<?php $box = array(); ?>
<?php $data = array(); ?>

<?php //MATRIZ DE RESERVAS VACIA ?>
<?php foreach ($gestdent_hora_list as $gestdent_hora): ?>
    <?php foreach ($gestdent_box_list as $gestdent_box): ?>
        <?php $data["Doctor"] = ""; ?>
        <?php $data["Paciente"] = ""; ?>
        <?php $data["Confirmado"] = false; ?>
        <?php $data["Recepcionado"] = false; ?>
        <?php $box[$gestdent_box->getNombre()] = $data; ?>
        <?php $agenda[$gestdent_hora->getId()] = $box; ?>
    <?php endforeach; ?>
<?php endforeach; ?>

<?php //LLENAMOS MATRIZ DE RESERVAS ?>
<?php foreach ($gestdent_reserva_list as $gestdent_reserva): ?>
    <?php $aleatorio = mt_rand(1,5); ?>
    <?php $agenda[$gestdent_reserva->getHora()]["Box-".$aleatorio]["Doctor"] = $gestdent_reserva->getGestdentPersonal()->getNombres()." ".$gestdent_reserva->getGestdentPersonal()->getApellidoPaterno() ?>
    <?php $agenda[$gestdent_reserva->getHora()]["Box-".$aleatorio]["Paciente"] = "Paciente: ".$gestdent_reserva->getGestdentPaciente()->getNombres()." ".$gestdent_reserva->getGestdentPaciente()->getApellidoPaterno() ?>
    <?php $agenda[$gestdent_reserva->getHora()]["Box-".$aleatorio]["Confirmado"] = $gestdent_reserva->getConfirmado() ?>
    <?php $agenda[$gestdent_reserva->getHora()]["Box-".$aleatorio]["Recepcionado"] = $gestdent_reserva->getRecepcionado() ?>
<?php endforeach; ?>

<table>
    <thead>
        <th><?php echo "Hora/Box" ?></th>
        <?php foreach ($gestdent_box_list as $gestdent_box): ?>
        <th><?php echo $gestdent_box->getNombre() ?></th>
        <?php endforeach; ?>
    </thead>

    <tbody>
        <?php foreach ($gestdent_hora_list as $gestdent_hora): ?>
        <tr>
            <td>
                <?php echo $gestdent_hora->getDescripcion() ?>
            </td>

            <?php foreach ($gestdent_box_list as $gestdent_box): ?>
            <td>
                <b><i><?php echo $agenda[$gestdent_hora->getId()][$gestdent_box->getNombre()]["Paciente"]; ?></i></b>
            </td>
            <?php endforeach; ?>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<pre><?php //print_r ($agenda); ?></pre>
